/*
 * Albareth - an action roleplaying game.
 * Copyright (C) 2008 Jens Anuth
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 *  02110-1301, USA.
 * 
 * $Id: SchedulerTestFrame.java 46 2008-05-15 18:09:39Z jens464 $
*/
package albareth.tests;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

import frosch.util.Task;
import frosch.util.TaskScheduler;

import albareth.frontend.slick.SlickResources;
import albareth.frontend.slick.ui.UIElement;

/**
 * UI element to visualize the content of the TaskScheduler.
 */
public class SchedulerTestFrame extends UIElement
{
    private TaskScheduler _scheduler;
    
    public SchedulerTestFrame(TaskScheduler scheduler)
    {
        _scheduler = scheduler;
        setSize(300, 300);
        setFont(SlickResources.SMALL_FONT);
        setForegroundColor(Color.white);
        setOpaque(false);
        
    }

    public void render(Graphics g, GameContainer container, int screenX,
            int screenY) throws SlickException
    {
        g.drawString("Time:"+String.valueOf(_scheduler.getCurrentTime()), 0, 0);
        g.drawString("Tasks:"+String.valueOf(_scheduler.getSize()), 150, 0);
        Task[] tasks = _scheduler.getQueue();
        for (int i = 0; i < _scheduler.getSize(); i++)
        {
            if (tasks[i] != null)
            {
                g.drawString(tasks[i].getClass().toString(), 0, i*10 + 10);
                g.drawString(String.valueOf(tasks[i].getNextExecutionTime()), 250, i*10 + 10);
            }

        }
    }

}
